package com.et.sale.order.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.et.sale.deposit.entity.DepositEntity;
import com.et.sale.order.entity.OrderEntity;
import com.et.sale.order.service.OrderService;


@Controller
@RequestMapping("/order")
public class OrderController {
	
	
	@Autowired OrderService service;
	
	
	@RequestMapping("/add")
	public String addSave(OrderEntity entity,HttpServletRequest request){
		
		Integer userId = null;
		Object object = request.getSession().getAttribute("userId");
		if(null == object){
			return "user/login";
		}else{
			//1：入参的检查
			
			//2: 调用service 插入到数据库
			userId = Integer.parseInt(object.toString());
			entity.setUserId(userId);
			int qty  =service.addSave(entity);
			
		    //3: 返回到列表页面 
			return "success";
		}
		
		
	}
}
